package org.lanqiao.sjx.dao.impl;

import java.sql.SQLException;
import java.util.List;

import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.lanqiao.bean.Education;
import org.lanqiao.bean.Zuopin;
import org.lanqiao.sjx.dao.ZuopinDao;
import org.lanqiao.tools.BaseDao;

public class ZuopinImpl extends BaseDao implements ZuopinDao {

	@Override
	public Integer insertZuopin(Zuopin info) {
		String sql="insert into zuopin(userId,herf,zpDescription,date) values(?,?,?,Now())";
		try {
			return query.update(sql,info.getUserId(),info.getHerf(),info.getZpDescription());
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public Integer deleteZuopin(Integer id,Integer userId) {
		String sql="delete from  work where id=? and userId=?";
		try {
			return query.update(sql,id,userId);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public List<Zuopin> selectZuopin(Integer userId) {
		String sql="select * from zuopin where userId=?";
		try {
			System.out.println(userId);
			return query.query(sql, new BeanListHandler<Zuopin>(Zuopin.class),userId);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public Integer updateZuopin(Zuopin info) {
		String sql="update zuopin set  herf=?,zpDescription=?,date=Now() where id=? ";
		try {
			return query.update(sql,info.getHerf(),info.getZpDescription(),info.getId());
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public Integer getCountZP() {
		// TODO Auto-generated method stub
		return null;
	}

}
